/**
 * 文件数据日期器
 */
package com.flute.framework.business;

import java.io.InputStream;

import com.flute.framework.configuration.FileDataPreparerXMLConverter;
import com.flute.framework.data.preparer.FileDataPreparer;
import com.flute.framework.exception.ConfigurationParseException;
import com.flute.tools.timer.FlexTimer;

/**
 * @author Jazz
 * 
 */
public class TimerFileData {
	private FileDataPreparer preparer;
	private long updateInterval;

	public TimerFileData(InputStream stream) throws ConfigurationParseException {
		TimerFileData timerBusinessInfo = FileDataPreparerXMLConverter
				.getTimerFileDataInfo(stream);
		this.preparer = timerBusinessInfo.getPreparer();
		this.updateInterval = timerBusinessInfo.updateInterval;
	}

	public void start() {
		FlexTimer.getInstance().startTimer(preparer.getFilePreparerName(),
				preparer, "preparerData", updateInterval, true);
	}

	public void stop() {
		FlexTimer.getInstance().stopTimer(preparer.getFilePreparerName());
	}

	public FileDataPreparer getPreparer() {
		return preparer;
	}

	public void setPreparer(FileDataPreparer preparer) {
		this.preparer = preparer;
	}

	public long getUpdateInterval() {
		return updateInterval;
	}

	public void setUpdateInterval(long updateInterval) {
		this.updateInterval = updateInterval;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
